package com.mdp.workflow.bus.candidate.strategy;


import cn.hutool.core.lang.Assert;
import com.mdp.core.utils.StrUtils;
import com.mdp.workflow.bus.candidate.TaskCandidateStrategy;
import com.mdp.workflow.client.service.WfSysUserService;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

/**
 * 部门的成员 {@link TaskCandidateStrategy} 实现类
 *
 * @author kyle
 *@author 唛盟开源 9哥
 */
@Component
public class DeptMemberStrategy implements TaskCandidateStrategy {
    @Autowired
    WfSysUserService wfSysUserService;

    @Override
    public com.mdp.workflow.comm.dict.CandidateStrategy getStrategy() {
        return com.mdp.workflow.comm.dict.CandidateStrategy.DEPT_MEMBER;
    }

    @Override
    public void validateParam(String param) {
        Assert.notNull(param,"部门编号不能为空，多个以逗号分隔");
    }

    @Override
    public Set<String> calculateUsers(DelegateExecution execution, String param) {
        Set<String> depptids= StrUtils.splitToStringSet(param);
         return wfSysUserService.selectUseridsByDeptIds(depptids);
    }

}